
SELECT * FROM TM_DRAWDATA
GO

SELECT DISTINCT LEAGUEID FROM TM_EVENTO  ORDER BY LEAGUEID
GO

SELECT * FROM TM_EVENTO 
GO
GO

ALTER TABLE TM_LIGA DROP COLUMN "LASTFECHAUPDATE" 
go

SELECT LIGA,nombre,ALIAS,ALIAS_INTRALOT,ALIAS_LIVESCORE FROM TM_EQUIPO 
WHERE NOMBRE LIKE '%Newells%'
order by liga,nombre
go


ALTER TABLE TM_LIGA ADD COLUMN "LASTFECHAUPDATE" TIMESTAMP
go

    PRIVATE BIGDECIMAL GOAL_SCORED_1T;
    PRIVATE BIGDECIMAL GOAL_SCORED_2T;
    PRIVATE BIGDECIMAL GOAL_CONCEDED_1T;
    PRIVATE BIGDECIMAL GOAL_CONCEDED_2T;
    PRIVATE BIGDECIMAL AVG_CONCEDED_LOCAL;
    PRIVATE BIGDECIMAL AVG_CONCEDED_VISITA;

    PRIVATE BIGDECIMAL AVG_SCORED_LOCAL;
    PRIVATE BIGDECIMAL AVG_SCORED_VISITA;

go

SELECT * FROM TM_EQUIPO 
--where NOMBRE like '%Belgium%'
order by liga
go

select * from TM_LIGA L 
    inner join TM_EVENTO E ON E.LEAGUEID LIKE '%'||L.LEAGUEID||'%'
go

SELECT DISTINCT E.LEAGUEID
FROM
	TM_EVENTO E INNER JOIN TM_DRAWDATA D ON D.DRAWID=E.DRAWID
WHERE 
 D.FECHA >=  dateadd('hour', -1, CURRENT_DATE)

/*

DELETE FROM TM_DRAWDATA
GO

DELETE FROM TM_EQUIPO
GO

DELETE FROM TM_EVENTO
GO
DELETE FROM TM_LIGA
GO

DELETE FROM TM_FECHA
GO*/

select * from TM_FECHA 
go

select LIGA, COUNT(*) from tm_fecha where remontada='1' GROUP BY LIGA ORDER BY 2 DESC

select liga, fecha, equipo1,equipo2,primertiempo,resultadofinal from tm_fecha where remontada='1' 
AND FECHA >  ADD_MONTHS ( DATE '2014-08-01' , 0)
ORDER BY LIGA,FECHA

--- Belgium GENT  LV
--- Brazil Vitoria LV
--- Brazil Flamengo LV
--- Brazil Cruzeiro LV
--- Brazil Sao Paulo  VL
--- Brazil2 Icasa VL
--- Colombia La Equidad VL
--- Colombia La Equidad VL
--- Denmark FC Nordsjaelland LV
--- England3 Bristol City   LV - VL
--- England4 -- > Tranmere Rovers    LV - VL
---  France-L2 Clermont Foot  VL
--- Germany2 -> Kaiserslautern     LV - VL
--- Mexico-> Leon  LV - VL
--- Norway2 -> Tromsdalen
--- Sweden -> Oerebro
--- USA -> New York Red Bulls



SELECT *
FROM
	TM_EVENTO E 
go

select * from tm_liga


INSERT INTO TM_EQUIPO (NOMBRE,LIGA) 
SELECT DISTINCT EQUIPO1,LIGA FROM TM_FECHA WHERE LIGA='PERU2'
GO
